package com.bidepan.特殊类型注入;

import java.util.Arrays;

public class Emp {
    //员工属于某个部门
    private Dept dept;

    private String Ename;
    private Integer age;

    private String[] hobbys;

    public void setHobbys(String[] hobbys) {
        this.hobbys = hobbys;
    }

    public void work(){
        System.out.println(Ename + " is working..."+"年龄："+age);
        System.out.println(Ename+"的爱好为："+Arrays.toString(hobbys));
        try{
            dept.info();
        }catch (Exception e){
            System.out.println(Ename+"所在的部门暂时没有其他员工");
        }
    }

    public void setDepart(Dept department) {
        this.dept = department;
    }

    public void setEname(String ename) {
        Ename = ename;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Emp{" +
                "dept=" + dept.getDname() +
                ", Ename='" + Ename + '\'' +
                ", age=" + age +
                ", hobbys=" + Arrays.toString(hobbys) +
                '}';
    }
}
